/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx.exam;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * <p>Project: javaseapp - Ex8
 * <p>Powered by webrx On 2021-08-08 16:17:32
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Ex8 {
    public static void main(String[] args) {
        String str = """
                <div>hello</div><div>java 15</div><div><p>java 15</p><span>java 8</p><div>java 15</div></div>
                """;

        Pattern p = Pattern.compile("<div>.java.</div>");
        Pattern p1 = Pattern.compile("<div>.*java.*</div>");
        Pattern p2 = Pattern.compile("<div>[\\w\\s]*?java[\\w\\s]*?</div>");
        Matcher m = p.matcher(str);
        Matcher m2 = p1.matcher(str);
        Matcher m3 = p2.matcher(str);
        while (m.find()) {
            System.out.println(m.group());
        }
        System.out.println("------------------------------------------------------");
        while (m2.find()) {
            System.out.println(m2.group());
        }
        System.out.println("------------------------------------------------------");
        while (m3.find()) {
            System.out.println(m3.group());
        }
    }
}
